<template>
  <el-form
      ref="formRef"
      :model="form"
      label-width="120px">
    <el-form-item label="phone">
      <el-input v-model="form.phone"></el-input>
    </el-form-item>
    <el-form-item label="password">
      <el-input type="password" v-model="form.password"></el-input>
    </el-form-item>
    <el-form-item label="position">
      <el-radio-group v-model="form.position">
        <el-radio label="crowd"></el-radio>
        <el-radio label="publisher"></el-radio>
        <el-radio label="admin"></el-radio>
      </el-radio-group>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">Login</el-button>
      <el-button>Cancel</el-button>
      <el-button @click="$router.push('/user/register')">register</el-button>
    </el-form-item>
  </el-form>
</template>

<script lang="ts" setup>
import {reactive} from 'vue'
import login from "@/api/user/login";


// do not use same name with ref
const form = reactive({
  id: -1,
  username: '',
  password: '',
  phone: '',
  email: '',
  position: '',
})


const onSubmit = async () => {
  await login(form);
}
</script>

<style scoped>

</style>